using System;
using System.Threading.Tasks;

namespace JGSY.CMS.LowCode.Platform.Application.Interfaces
{
    /// <summary>
    /// 缓存服务接口。
    /// 提供数据缓存的存储、获取、删除等缓存相关底层服务功能接口定义。
    /// </summary>
    public interface ICacheService
    {
        /// <summary>
        /// 设置缓存值
        /// </summary>
        /// <typeparam name="T">缓存数据类型</typeparam>
        /// <param name="key">缓存键</param>
        /// <param name="value">缓存值</param>
        /// <param name="ttl">过期时间（可选）</param>
        /// <returns>设置任务</returns>
        Task SetAsync<T>(string key, T value, TimeSpan? ttl = null);
        
        /// <summary>
        /// 获取缓存值
        /// </summary>
        /// <typeparam name="T">缓存数据类型</typeparam>
        /// <param name="key">缓存键</param>
        /// <returns>缓存值</returns>
        Task<T?> GetAsync<T>(string key);
        
        /// <summary>
        /// 移除缓存值
        /// </summary>
        /// <param name="key">缓存键</param>
        /// <returns>移除任务</returns>
        Task RemoveAsync(string key);
    }
}
